<?php

class lib_date {
    public function __construct() {
    }
    
    public static function get_now() {
        return date("Y-m-d H:i:s");
    }
    
    public static function get_datetime_now() {
        $temp = DateTime::createFromFormat("Y-m-d H:i:s", date("Y-m-d H:i:s"));
        return $temp;
    }
    
    public static function convert_to_datetime($date, $format) {
        $temp = DateTime::createFromFormat($format, $date);
        return $temp;
    }
    
    public static function convert_to_sql_date($date, $format) {
        $temp = DateTime::createFromFormat($format, $date);
        return date_format($temp, "Y-m-d");
    }
    
    public static function convert_to_sql_time($time, $format) {
        $temp = DateTime::createFromFormat($format, $time);
        return date_format($temp, "H:i");
    }
    
    public static function convert_to_sql_date_time($date_time, $format) {
        $temp = DateTime::createFromFormat($format, $date_time);
        return date_format($temp, "Y-m-d H:i:s");
    }
}
